#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QPixmap>
#include <QDesktopWidget>

MainWindow::MainWindow(QDialog *parent) :
    QDialog(parent),
    ui(new Ui::MainWindow)
{
    setWindowFlags(Qt::FramelessWindowHint);
    ui->setupUi(this);
//    resize(_DISPLAY_WIDTH, _DISPLAY_HEIGHT);
    pDevCtl = NULL;
    pDevCtl = new CDeviceCtrl(this);
    on_StartCapture_clicked();
}

MainWindow::~MainWindow()
{
    on_StopCapture_clicked();
    delete ui;
}



void MainWindow::on_StartCapture_clicked()
{
    if(NULL != pDevCtl)
    {
        if(-1 == pDevCtl->OpenDevice())
            return;
        pDevCtl->ReadAndDisplay();
        pBackup = new CRedundance(pDevCtl);
    }
}

void MainWindow::on_StopCapture_clicked()
{
    if(NULL != pDevCtl)
    {
        pDevCtl->CloseDevice();
    }
}

void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawPixmap(QRect(0, 0, 1024, 768), QPixmap("default.bmp"));
}
